package com.butcher.framework.kernel.endpoint.http.transform.xml;

import java.io.OutputStream;

import com.butcher.framework.kernel.endpoint.http.service.Service;
import com.butcher.framework.kernel.endpoint.http.transform.MessageContext;
import com.butcher.framework.kernel.endpoint.http.transform.Transform;
import com.butcher.framework.kernel.exc.FastHttpException;

public class XMLTransform implements Transform {
	@SuppressWarnings("unused")
	private static final String REQ_XML = "REQ_XML";
	@SuppressWarnings("unused")
	private static final String RES_XML = "RES_XML";

	public void consume(MessageContext context) throws FastHttpException {
		XMLTool.readXML(context);
	}

	public void produce(MessageContext context) throws FastHttpException {
		XMLTool.writeXML(context);
	}

	public void generateXJDL(OutputStream output, String queryString,
			Service service, String methodName) throws FastHttpException {
		if (queryString.equalsIgnoreCase("REQ_XML")) {
			XMLTool.generateRMDL(output, service, methodName);
		} else if (queryString.equalsIgnoreCase("RES_XML")) {
			XMLTool.generateRVDL(output, service, methodName);
		}
	}
}